This Notebook contains all the deliverables for our Presidential Analysis project. https://github.com/nickk752/presidential-data-science Be careful when running all cells, you will unleash the twitter bots.

Scrape Campaign Speeches This code will go to the American Presidency Project campaign speech url passed to scrapeCampaignSpeechesToFile and download all campaign speeches from all candidates in the given election year. These files are saved in ./Campaign Speeches/[Year]/[candidate-name.txt]


In [40]:
import pandas as pd
import numpy as np
import requests
from lxml import html
from bs4 import BeautifulSoup
import markovify
import os.path
from datetime import datetime, timedelta
import calendar
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
%matplotlib inline
import seaborn as sns
import re


def getCandidateSpeechLinks(url):
    allCandidatePage = requests.get(url)
    allCandidatePageSoup = BeautifulSoup(allCandidatePage.text, 'lxml')
    links={}
    table = allCandidatePageSoup.find('table', width=680)
    for area in table.findAll('td', class_='doctext'):
        for a in area.findAll('a'):
            if ('campaign' in a.text.lower()):
                links[area.find('span', class_='roman').text] = a['href']
    return links

def scrapeCampaignSpeechesToFile(url, path):
    allSpeechPages = requests.get(url)
    allSpeechSoup=BeautifulSoup(allSpeechPages.text, 'lxml')
    root = 'http://www.presidency.ucsb.edu/'
    table = allSpeechSoup.find('table', width=700)
    links = []
    for link in table.findAll('a'):
        if('interview' not in link.text.lower()):
            links.append(root+(link['href'])[3:])

    speechPages = [requests.get(link , 'lxml')for link in links]
    speechesSoup = [BeautifulSoup(speechPage.text, 'lxml') for speechPage in speechPages]

    with open(path, "w+", encoding='utf-8') as outFile:
        outFile.seek(0)
        for i,speech in enumerate(speechesSoup):            
            text = speechesSoup[i].find('span', class_='displaytext').text.replace('.','. ')
            text = re.sub('\[[a-zA-Z]*\]', ' ', text)
            text = re.sub('[A-Z]+ [A-Z]+:', ' ', text)
            text = re.sub('\w+:', ' ', text)
            text = re.sub(r'[^\x00-\x7F]+',' ', text)
            
            outFile.write(text +'\n')


def campaignLinkToFiles(url, year):
    
    dataFolder = './Campaign Speeches/'+ str(year) +'/'
    
    if not os.path.exists(dataFolder):
        os.makedirs(dataFolder)
    
    #Create the dictionary of each candidate's name and link to their campaign speech page    
    campaignSpeechLinkDict = getCandidateSpeechLinks(url)
    
    root = 'http://www.presidency.ucsb.edu/'
    new=0
    existing=0
    newpaths=[]
    #Loops through the campagin speech links, puts each candidate's campagin speeches into individual files
    for name, url in campaignSpeechLinkDict.items():
        path = dataFolder + name.replace(' ', '-') + '.txt'
        if not os.path.isfile(path):
            new+=1
            newpaths.append(path)
            scrapeCampaignSpeechesToFile(root + url, path)
        else:
            existing+=1
    
    
    
    #print some statistics
    print(str(existing), ' files already existed, ignoring.')
    print(str(new), ' files created successfully:')
    for p in newpaths:
        print(p)

campaignLinkToFiles('http://www.presidency.ucsb.edu/2016_election.php', 2016)


20  files already existed, ignoring.
1  files created successfully:
./Campaign Speeches/2016/Carly-Fiorina.txt

Scrape Tweets from Twitter This code will load api keys from twitterkeys.txt, log into the Donald Trump bot, and download every tweet from the candidates specified in ./Twitter/twitterhandles.json. These tweets are saved as ./Twitter/Tweets/[Tweeter-Name.txt]


In [2]:
import oauth2 as oauth
import urllib.request
from pprint import pprint
import csv
import re
import os
import tweepy
from tweepy import OAuthHandler
import json

keys_path = './twitterkeys.txt'
keys=[]

#load the twitter api keys
with open(keys_path) as f:
    keys=json.load(f)

accountToUse = 'Donald Trump'
keysToUse = keys[accountToUse]
auth = OAuthHandler(keysToUse['cons_key'], keysToUse['cons_secret'])
auth.set_access_token(keysToUse['access_token'], keysToUse['access_token_secret'])

api = tweepy.API(auth)

#load the list of twitter handles to scrape
handles=[]

with open('./Twitter/twitterhandles.json') as f:
    handles= json.load(f)
print(handles)

root = './Twitter/tweets/'

#accepts a twitter handle and a name for the candidate, downloads all the tweets for that candidate and stores them in 
def scrapeTweetsToFile(handle, name):
    
    print(handle)
    alltweets = []

    newtweets=api.user_timeline(screen_name = handle, count=200)
    alltweets.extend(newtweets)
    oldest=alltweets[-1].id -1

    while len(newtweets) > 0:
        print('getting tweets before %s' %(oldest))
        newtweets = api.user_timeline(screen_name=handle, count=200, max_id=oldest)    
        alltweets.extend(newtweets)    
        oldest=alltweets[-1].id - 1
        print('...%s tweets downloaded so far' % len(alltweets))

    outtweets = [[re.sub(r'[^\x00-\x7f]',r' ',tweet.text.replace('&', '&').strip("'").replace('"','').replace('\n', ' '))] for tweet in alltweets]

    with open(os.path.join(root, '%s.txt' % name.replace(' ','-')) , 'w+', encoding='utf8') as f:

        previous=''
        
        #These skip flags ensure that a continued tweet is not split in two
        skipnext=False
        skipcurrent=False
        
        #loop through all the tweets
        for t in outtweets:
            #move the skip next flag to the skip current flag
            skipcurrent=skipnext
            skipnext=False
            
            #if there is a previous tweet and the current tweet starts with '...'
            if previous!='':
                #if the current tweet has .. in the last 6 chars (Trump is messy with his ellipsies)
                if '..' in t[0][-6:]:
                    #set previous to the current tweet with the previous tweet appended to the end, removing all ellipsis-like patterns
                    previous=t[0].strip('...').replace('...',' ')+' '+previous.strip('...').replace('...',' ')
                    #set the flag to skip the next entry
                    skipnext=True
            #if there is a previous tweet that is not a retweet or a reply, and there are no links in the tweet
            if previous != '' and previous[:2] != 'RT' and not '@' in previous[:2] and 'http' not in previous and not skipcurrent: 
                #write the previous tweet to its file
                f.write(previous+'\n') 
            
            #set the previous tweet
            previous=t[0]
    pass

#loop through the twitter handles and scrape the tweets of each one into a file
for handle in handles:
    scrapeTweetsToFile(handles[handle], handle)


{'Ted Cruz': 'tedcruz', 'Donald Trump': 'realDonaldTrump', 'President Obama': 'potus44', 'Bernie Sanders': 'BernieSanders', 'Barack Obama': 'BarackObama', 'Hillary Clinton': 'HillaryClinton'}
tedcruz
getting tweets before 846838294876950527
...400 tweets downloaded so far
getting tweets before 831268728595701761
...600 tweets downloaded so far
getting tweets before 819312643425058815
...800 tweets downloaded so far
getting tweets before 806605605104472064
...999 tweets downloaded so far
getting tweets before 796132220054466559
...1195 tweets downloaded so far
getting tweets before 789315011000664065
...1395 tweets downloaded so far
getting tweets before 781533806335438847
...1595 tweets downloaded so far
getting tweets before 772982519209693183
...1795 tweets downloaded so far
getting tweets before 759133467313438719
...1995 tweets downloaded so far
getting tweets before 748180284785332223
...2195 tweets downloaded so far
getting tweets before 734725803359903744
...2393 tweets downloaded so far
getting tweets before 726057446444146688
...2592 tweets downloaded so far
getting tweets before 723886626439491583
...2791 tweets downloaded so far
getting tweets before 721749740497448960
...2989 tweets downloaded so far
getting tweets before 719688480322785279
...3187 tweets downloaded so far
getting tweets before 716768717879644160
...3227 tweets downloaded so far
getting tweets before 716304071011885056
...3227 tweets downloaded so far
realDonaldTrump
getting tweets before 847455180912181248
...400 tweets downloaded so far
getting tweets before 830751875578355712
...600 tweets downloaded so far
getting tweets before 819550083742109695
...800 tweets downloaded so far
getting tweets before 806134244384899071
...999 tweets downloaded so far
getting tweets before 793796754193936384
...1199 tweets downloaded so far
getting tweets before 788923410353008639
...1399 tweets downloaded so far
getting tweets before 785301286816210943
...1599 tweets downloaded so far
getting tweets before 780642262921441279
...1799 tweets downloaded so far
getting tweets before 772928797419143167
...1999 tweets downloaded so far
getting tweets before 764254551822196736
...2199 tweets downloaded so far
getting tweets before 758511494669664255
...2399 tweets downloaded so far
getting tweets before 752591157641744383
...2599 tweets downloaded so far
getting tweets before 744355251365511168
...2799 tweets downloaded so far
getting tweets before 737376803514286080
...2999 tweets downloaded so far
getting tweets before 731801917379219455
...3199 tweets downloaded so far
getting tweets before 724662038220423167
...3242 tweets downloaded so far
getting tweets before 722592772096724996
...3242 tweets downloaded so far
potus44
getting tweets before 656894040319791103
...352 tweets downloaded so far
getting tweets before 600324682190053375
...352 tweets downloaded so far
BernieSanders
getting tweets before 831963509013540864
...400 tweets downloaded so far
getting tweets before 814528733193375744
...600 tweets downloaded so far
getting tweets before 795724257129103363
...800 tweets downloaded so far
getting tweets before 786743577791516671
...1000 tweets downloaded so far
getting tweets before 776541004727980031
...1200 tweets downloaded so far
getting tweets before 764918640747491328
...1400 tweets downloaded so far
getting tweets before 756315217651380224
...1599 tweets downloaded so far
getting tweets before 748296270737874944
...1799 tweets downloaded so far
getting tweets before 740603686611759103
...1999 tweets downloaded so far
getting tweets before 735478286336196607
...2199 tweets downloaded so far
getting tweets before 728960607567814655
...2399 tweets downloaded so far
getting tweets before 722616198584745983
...2599 tweets downloaded so far
getting tweets before 719206817570496511
...2799 tweets downloaded so far
getting tweets before 715322238778511359
...2999 tweets downloaded so far
getting tweets before 711709917334233087
...3199 tweets downloaded so far
getting tweets before 708675931817119744
...3243 tweets downloaded so far
getting tweets before 707760904872439811
...3243 tweets downloaded so far
BarackObama
getting tweets before 773549731901349887
...400 tweets downloaded so far
getting tweets before 747152944047362048
...600 tweets downloaded so far
getting tweets before 723638166243016703
...800 tweets downloaded so far
getting tweets before 702936121659920383
...1000 tweets downloaded so far
getting tweets before 686966611064926207
...1200 tweets downloaded so far
getting tweets before 666354177400897539
...1400 tweets downloaded so far
getting tweets before 646093630315192319
...1600 tweets downloaded so far
getting tweets before 627914442227888127
...1800 tweets downloaded so far
getting tweets before 614505702296453119
...2000 tweets downloaded so far
getting tweets before 596717288566358015
...2200 tweets downloaded so far
getting tweets before 578308711833214975
...2399 tweets downloaded so far
getting tweets before 557738590818795519
...2599 tweets downloaded so far
getting tweets before 544580050012491775
...2798 tweets downloaded so far
getting tweets before 532909143573528575
...2998 tweets downloaded so far
getting tweets before 515870800424222719
...3198 tweets downloaded so far
getting tweets before 497412858599075841
...3231 tweets downloaded so far
getting tweets before 494959325102620672
...3231 tweets downloaded so far
HillaryClinton
getting tweets before 795442237664612351
...400 tweets downloaded so far
getting tweets before 793522628791271423
...600 tweets downloaded so far
getting tweets before 790737990985326591
...800 tweets downloaded so far
getting tweets before 788910585207459839
...1000 tweets downloaded so far
getting tweets before 785907463065329663
...1200 tweets downloaded so far
getting tweets before 783669207040946175
...1400 tweets downloaded so far
getting tweets before 781890612069036031
...1600 tweets downloaded so far
getting tweets before 780088306314928127
...1800 tweets downloaded so far
getting tweets before 776782857993916415
...2000 tweets downloaded so far
getting tweets before 774022125510197248
...2200 tweets downloaded so far
getting tweets before 770299979533586431
...2400 tweets downloaded so far
getting tweets before 765294117647777791
...2600 tweets downloaded so far
getting tweets before 761603088826396672
...2800 tweets downloaded so far
getting tweets before 758805859791097856
...3000 tweets downloaded so far
getting tweets before 757989498982658048
...3200 tweets downloaded so far
getting tweets before 756315520484384768
...3240 tweets downloaded so far
getting tweets before 755950742310154240
...3240 tweets downloaded so far

In [3]:
import string
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import nltk
import glob
import os
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.cluster import KMeans
from scipy.cluster.vq import whiten
import re
from sklearn.model_selection import train_test_split
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_moons, make_circles, make_classification
from sklearn.neural_network import MLPClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.model_selection import cross_val_score
%matplotlib inline

def token_to_pos(ch):
    tokens = nltk.word_tokenize(ch)
    return [p[1] for p in nltk.pos_tag(tokens)]
    

def corpustovector(corpus):
        # create feature vectors
    num_tweets = len(corpus)
    fvs_lexical = np.zeros((len(corpus), 3), np.float64)
    fvs_punct = np.zeros((len(corpus), 3), np.float64)



    for e, tw_text in enumerate(corpus):
        # note: the nltk.word_tokenize includes punctuation
        tokens = nltk.word_tokenize(tw_text.lower())
        words = word_tokenizer.tokenize(tw_text.lower())
        sentences = sentence_tokenizer.tokenize(tw_text)
        vocab = set(words)
        words_per_sentence = np.array([len(word_tokenizer.tokenize(s)) for s in sentences])

        # average number of words per sentence
        fvs_lexical[e, 0] = words_per_sentence.mean()
        # sentence length variation
        fvs_lexical[e, 1] = words_per_sentence.std()
        # Lexical diversity
        fvs_lexical[e, 2] = len(vocab) / float(len(words))

        # Commas per sentence
        fvs_punct[e, 0] = tokens.count(',') / float(len(sentences))
        # Exclamations per sentence
        fvs_punct[e, 1] = tokens.count('!') / float(len(sentences))
        # Colons per sentence
        fvs_punct[e, 2] = tokens.count(':') / float(len(sentences))     
        
 
    # apply whitening to decorrelate the features
    fvs_lexical = whiten(fvs_lexical)
    fvs_punct = whiten(fvs_punct)
    
    # get most common words in the whole book
    NUM_TOP_WORDS = 10
    
    translator = str.maketrans('', '', string.punctuation)

    all_text = ' '.join(corpus)
    all_tokens = nltk.word_tokenize(all_text.translate(translator))
    fdist = nltk.FreqDist(all_tokens)
    vocab = sorted(fdist, key=fdist.get, reverse=True)[:NUM_TOP_WORDS]

    # use sklearn to create the bag for words feature vector for each speech
    vectorizer = CountVectorizer(vocabulary=vocab, tokenizer=nltk.word_tokenize)
    fvs_bow = vectorizer.fit_transform(corpus).toarray().astype(np.float64)

    # normalise by dividing each row by its Euclidean norm
    fvs_bow /= np.c_[np.apply_along_axis(np.linalg.norm, 1, fvs_bow)]
    fvs_bow = np.nan_to_num(fvs_bow)
    
    
    tweets_pos = [token_to_pos(tw) for tw in corpus]
 
    # count frequencies for common POS types
    pos_list = ['NN', 'NNP', 'DT', 'IN', 'JJ', 'NNS']
    fvs_syntax = np.array([[tw.count(pos) for pos in pos_list]
                           for tw in tweets_pos]).astype(np.float64)


    # normalise by dividing each row by number of tokens in the chapter
    fvs_syntax /= np.c_[np.array([len(tw) for tw in tweets_pos])]
    
    
    fvs = np.c_[fvs_lexical , fvs_punct , fvs_bow, fvs_syntax]
    cols=['mean-wps', 'std-wps', 'div-wps', 'commas','ats','colons','bow1','bow2','bow3','bow4','bow5','bow6','bow7','bow8','bow9','bow10','NN', 'NNP', 'DT', 'IN', 'JJ', 'NNS']
    dfCorpus = pd.DataFrame(fvs, columns=cols)
    print(dfCorpus.shape)
    return dfCorpus

In [4]:
nltk.data.path.append('N:\\nltk_data')
sentence_tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
word_tokenizer = nltk.tokenize.RegexpTokenizer(r'\w+')

def concat_tweets(tweets, n):
    concatenated = []
    for i in range(len(tweets) // n):
        appendable = ''
        for x in range(n):
            appendable += (tweets[i + x*n] + ' ')
        concatenated.append(str(appendable)) 
    return concatenated

# Load data
folder = './Campaign Speeches/2016/nltk'
folder2 ='./Twitter/tweets/nltk/'
tweets=[]
labels = []
row_labels = []
for e, file in enumerate(os.listdir(folder)):
    with open(os.path.join(folder, file)) as f:
        newTweets = f.read().split('\n')
        newTweets.pop()
        newTweetsConcat = concat_tweets(newTweets, 1)
        print('Number of Tweets for', \
              file.strip('.txt'), ':', len(newTweetsConcat))
        tweets=tweets+newTweetsConcat
        labels.append(file.strip('.txt'))
        for i in range(len(newTweetsConcat)):
            row_labels.append(e)

dfFeatures = corpustovector(tweets)
df = pd.DataFrame()
df['tweets'] = tweets
df['label'] = row_labels


Number of Tweets for Bernie-Sanders : 29
Number of Tweets for Donald-Trump : 74
(103, 22)

Train several machine learning classifiers on the tweet data


In [5]:
X = dfFeatures
y = df['label']

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.33)

names= ['kNN', 'Decision Tree', 'Random Forest', 'MLP', 'AdaBoost', 'Gaussian']

#Defines each classifier and puts them in an array
classifiers = [
    KNeighborsClassifier(3),
    DecisionTreeClassifier(max_depth=5),
    RandomForestClassifier(),
    MLPClassifier(alpha=1, max_iter=1000),
    AdaBoostClassifier(n_estimators = 20, algorithm='SAMME'),
    GaussianNB()]

allScores=[]
# iterate over classifiers
for name, clf in zip(names, classifiers):
    clf.fit(X_train, y_train)
    scores =  clf.score(X_test, y_test)
    print(clf)
    print("Accuracy: %0.2f (+/- %0.2f)" % (scores.mean(), scores.std() * 2))
    allScores.append(scores.mean())
    print()


KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
           metric_params=None, n_jobs=1, n_neighbors=3, p=2,
           weights='uniform')
Accuracy: 0.82 (+/- 0.00)

DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=5,
            max_features=None, max_leaf_nodes=None,
            min_impurity_split=1e-07, min_samples_leaf=1,
            min_samples_split=2, min_weight_fraction_leaf=0.0,
            presort=False, random_state=None, splitter='best')
Accuracy: 0.91 (+/- 0.00)

RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
            max_depth=None, max_features='auto', max_leaf_nodes=None,
            min_impurity_split=1e-07, min_samples_leaf=1,
            min_samples_split=2, min_weight_fraction_leaf=0.0,
            n_estimators=10, n_jobs=1, oob_score=False, random_state=None,
            verbose=0, warm_start=False)
Accuracy: 0.97 (+/- 0.00)

MLPClassifier(activation='relu', alpha=1, batch_size='auto', beta_1=0.9,
       beta_2=0.999, early_stopping=False, epsilon=1e-08,
       hidden_layer_sizes=(100,), learning_rate='constant',
       learning_rate_init=0.001, max_iter=1000, momentum=0.9,
       nesterovs_momentum=True, power_t=0.5, random_state=None,
       shuffle=True, solver='adam', tol=0.0001, validation_fraction=0.1,
       verbose=False, warm_start=False)
Accuracy: 0.94 (+/- 0.00)

AdaBoostClassifier(algorithm='SAMME', base_estimator=None, learning_rate=1.0,
          n_estimators=20, random_state=None)
Accuracy: 0.94 (+/- 0.00)

GaussianNB(priors=None)
Accuracy: 0.82 (+/- 0.00)

Use PCA to reduce the feature vector to 2 dimensions, train the machine learning classifiers on the result, and graph the visualization of each classifier in 2d space


In [6]:
pca = PCA(n_components=2, svd_solver='full')
pca.fit(X)
pcavecs = pca.transform(X)

#figure = plt.figure()
i = 1
# iterate over datasets
h=.02
# preprocess dataset, split into training and test part
X = pcavecs
y = df['label']
X = StandardScaler().fit_transform(X)
X_train, X_test, y_train, y_test = \
    train_test_split(X, y, test_size=.4, random_state=42)
 
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
                     np.arange(y_min, y_max, h))
 
# just plot the dataset first
cm = plt.cm.RdBu
cm_bright = matplotlib.colors.ListedColormap(['#FF0000', '#0000FF'])
ax = plt.subplot()
 
# Plot the training points
ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright)
# and testing points
ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6)
ax.set_xlim(xx.min(), xx.max())
ax.set_ylim(yy.min(), yy.max())
ax.set_xticks(())
ax.set_yticks(())
i += 1
 
# iterate over classifiers
for name, clf in zip(names, classifiers):
    plt.figure()
    ax = plt.subplot()
    clf.fit(X_train, y_train)
    score = clf.score(X_test, y_test)

 
    # Plot the decision boundary. For that, we will assign a color to each
    # point in the mesh [x_min, x_max]x[y_min, y_max].
    if hasattr(clf, "decision_function"):
        Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])            
    else:
        Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
 
    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)
 
 
    # Plot also the training points
    ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright)
    # and testing points
    ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,
               alpha=0.6)
 
    ax.set_xlim(xx.min(), xx.max())
    ax.set_ylim(yy.min(), yy.max())
    ax.set_xticks(())
    ax.set_yticks(())
    ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),
            size=15, horizontalalignment='right')
    plt.title(name)
 
plt.tight_layout()
#plt.show()



In [7]:
def predict_politician_per_classifer(features, labels, classifer):
    lexical = ['mean-wps', 'std-wps', 'div-wps']
    punc = ['commas', 'ats', 'colons']
    bow = ['bow1','bow2','bow3','bow4','bow5','bow6','bow7','bow8','bow9','bow10']
    syntactic = ['NN', 'NNP', 'DT', 'IN', 'JJ', 'NNS']

    feature_sets = [lexical, punc, bow, syntactic]
    feature_set_names = ['Lexical', 'Punctuation', 'Bag of Words', 'Syntactic']
    
    accuracies = ''
    
    for feature_set, name in zip(feature_sets, feature_set_names):
        X_train, X_test, y_train, y_test = \
            train_test_split(features[feature_set], labels, test_size=.4)
        clf = classifer
        clf.fit(X_train, y_train)
        score = clf.score(X_test, y_test)
        score_str = "%0.2f (+/- %0.2f)" % (score.mean(), score.std() * 2)
        accuracy_str = str(name + ': ' + score_str)
        accuracies += (accuracy_str + '\n')
    
    return accuracies

In [8]:
names= ['kNN', 'Decision Tree', 'Random Forest', 'MLP', 'AdaBoost', 'Gaussian']

#Defines each classifier and puts them in an array
classifiers = [
    KNeighborsClassifier(3),
    DecisionTreeClassifier(max_depth=5),
    RandomForestClassifier(),
    MLPClassifier(alpha=1, max_iter=1000),
    AdaBoostClassifier(n_estimators = 20, algorithm='SAMME'),
    GaussianNB()]

for clf, name in zip(classifiers, names):
    print(name, str(':\n'+ predict_politician_per_classifer(dfFeatures, row_labels, clf)))


kNN :
Lexical: 0.90 (+/- 0.00)
Punctuation: 0.67 (+/- 0.00)
Bag of Words: 0.88 (+/- 0.00)
Syntactic: 0.95 (+/- 0.00)

Decision Tree :
Lexical: 0.81 (+/- 0.00)
Punctuation: 0.67 (+/- 0.00)
Bag of Words: 0.90 (+/- 0.00)
Syntactic: 0.81 (+/- 0.00)

Random Forest :
Lexical: 0.83 (+/- 0.00)
Punctuation: 0.67 (+/- 0.00)
Bag of Words: 0.90 (+/- 0.00)
Syntactic: 0.88 (+/- 0.00)

MLP :
Lexical: 0.93 (+/- 0.00)
Punctuation: 0.79 (+/- 0.00)
Bag of Words: 0.83 (+/- 0.00)
Syntactic: 0.79 (+/- 0.00)

AdaBoost :
Lexical: 0.93 (+/- 0.00)
Punctuation: 0.76 (+/- 0.00)
Bag of Words: 0.93 (+/- 0.00)
Syntactic: 0.86 (+/- 0.00)

Gaussian :
Lexical: 0.81 (+/- 0.00)
Punctuation: 0.69 (+/- 0.00)
Bag of Words: 0.95 (+/- 0.00)
Syntactic: 0.83 (+/- 0.00)

Now time to build the classifier for campaign speeches!


In [9]:
root='./Campaign Speeches/2016/nltk/'
candidates=os.listdir(root)
tweets=[]
labels = []
y=[]
for e, file in enumerate(os.listdir(root)):
    with open(os.path.join(root, file)) as f:
        newTweets = f.read().split('\n')
        newTweets.pop()
        tweets=tweets+newTweets
        for i in range(len(newTweets)):
            labels.append(file.strip('.txt'))
            y.append(e)
        
all_text = ' '.join(tweets)

dfFeatures = corpustovector(tweets)
df=pd.DataFrame()
df['tweets']=tweets
df['label']=y


(103, 22)

In [10]:
X = dfFeatures
y = df['label']


names= ['kNN', 'Decision Tree', 'Random Forest', 'MLP', 'AdaBoost', 'gaus']

#Defines each classifier and puts them in an array
classifiers = [
    KNeighborsClassifier(3),
    DecisionTreeClassifier(max_depth=5),
    RandomForestClassifier(warm_start=True, n_jobs=-1, n_estimators =20, max_depth=19,  max_features=None, criterion='entropy'),
    MLPClassifier(alpha=1, max_iter=1000),
    AdaBoostClassifier(n_estimators = 20, algorithm='SAMME'),
    GaussianNB()]


allScores=[]
# iterate over classifiers
for name, clf in zip(names,
                     classifiers):
    scores =  cross_val_score(clf, X, y, cv=5)
    print(clf)
    print("Accuracy: %0.2f (+/- %0.2f)" % (scores.mean(), scores.std() * 2))
    allScores.append(scores.mean())
    print()


KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
           metric_params=None, n_jobs=1, n_neighbors=3, p=2,
           weights='uniform')
Accuracy: 0.79 (+/- 0.16)

DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=5,
            max_features=None, max_leaf_nodes=None,
            min_impurity_split=1e-07, min_samples_leaf=1,
            min_samples_split=2, min_weight_fraction_leaf=0.0,
            presort=False, random_state=None, splitter='best')
Accuracy: 0.86 (+/- 0.32)

RandomForestClassifier(bootstrap=True, class_weight=None, criterion='entropy',
            max_depth=19, max_features=None, max_leaf_nodes=None,
            min_impurity_split=1e-07, min_samples_leaf=1,
            min_samples_split=2, min_weight_fraction_leaf=0.0,
            n_estimators=20, n_jobs=-1, oob_score=False, random_state=None,
            verbose=0, warm_start=True)
Accuracy: 0.88 (+/- 0.27)

MLPClassifier(activation='relu', alpha=1, batch_size='auto', beta_1=0.9,
       beta_2=0.999, early_stopping=False, epsilon=1e-08,
       hidden_layer_sizes=(100,), learning_rate='constant',
       learning_rate_init=0.001, max_iter=1000, momentum=0.9,
       nesterovs_momentum=True, power_t=0.5, random_state=None,
       shuffle=True, solver='adam', tol=0.0001, validation_fraction=0.1,
       verbose=False, warm_start=False)
Accuracy: 0.88 (+/- 0.20)

AdaBoostClassifier(algorithm='SAMME', base_estimator=None, learning_rate=1.0,
          n_estimators=20, random_state=None)
Accuracy: 0.93 (+/- 0.14)

GaussianNB(priors=None)
Accuracy: 0.87 (+/- 0.17)


In [11]:
pca = PCA(n_components=2, svd_solver='full')
pca.fit(dfFeatures)
pcavecs = pca.transform(dfFeatures)

i = 1
# iterate over datasets
h=.02
# preprocess dataset, split into training and test part
X = pcavecs
y = df['label']
X = StandardScaler().fit_transform(X)
X_train, X_test, y_train, y_test = \
    train_test_split(X, y, test_size=.4, random_state=42)

x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
                     np.arange(y_min, y_max, h))

# just plot the dataset first
cm = plt.cm.RdBu
cm_bright = matplotlib.colors.ListedColormap(['#FF0000', '#0000FF'])
ax = plt.subplot()

# Plot the training points
ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright)
# and testing points
ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6)
ax.set_xlim(xx.min(), xx.max())
ax.set_ylim(yy.min(), yy.max())
ax.set_xticks(())
ax.set_yticks(())
i += 1

# iterate over classifiers
for name, clf in zip(names, classifiers):
    plt.figure()
    ax = plt.subplot()
    #ax.set_title(name+' '+sub+', '+' vs '.join(candidates))
    ax.set_title(name+', '+' vs '.join(candidates))
    clf.fit(X_train, y_train)
    score = clf.score(X_test, y_test)

    # Plot the decision boundary. For that, we will assign a color to each
    # point in the mesh [x_min, x_max]x[y_min, y_max].
    if hasattr(clf, "decision_function"):
        Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])            
    else:
        Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)


    # Plot also the training points
    ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright)
    # and testing points
    ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,
               alpha=0.6)

    ax.set_xlim(xx.min(), xx.max())
    ax.set_ylim(yy.min(), yy.max())
    ax.set_xticks(())
    ax.set_yticks(())
    ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),
            size=15, horizontalalignment='right')
    i += 1

plt.tight_layout()


Twitter Bot


In [31]:
import twitter
import os
from markovbot import MarkovBot
import json
from pprint import pprint
import markovify
from html.parser import HTMLParser

keys_path = './twitterkeys.txt'
speech_root='./Campaign Speeches/2016/'
handles_path='./Twitter/twitterhandles.json'


keys=[]

#load the twitter api keys
with open(keys_path) as f:
    keys=json.load(f)


presidents=[p for p in keys]
print('Found Twitter API Keys for: ',', '.join(presidents))


bots={}

#get path to tweets from all the candidates
root = './Twitter/Tweets'
tweet_paths = [f for f in os.listdir(root) if os.path.isfile(os.path.join(root, f))]
print('Found Tweets for ', ', '.join(tweet_paths))


Found Twitter API Keys for:  Hillary Clinton, Donald Trump, Bernie Sanders
Found Tweets for  Ben-Carson.txt, Bernie-Sanders.txt, Bobby-Jindal.txt, Chris-Christie.txt, Donald-Trump.txt, George-Pataki.txt, Hillary-Clinton-.txt, Jeb-Bush.txt, Jim-Webb.txt, John-Kasich.txt, Lincoln-Chafee.txt, Lindsey-Graham.txt, Marco-Rubio.txt, Martin-O'Malley.txt, Mike-Huckabee.txt, Rand-Paul.txt, Rick-Perry.txt, Rick-Santorum.txt, Scott-Walker.txt, Ted-Cruz.txt

In [32]:
#make a markov bot for each politician's tweets
for path in tweet_paths:
    bot = MarkovBot()
    corpus = os.path.join(root, path)
    bot.read(corpus)
    #Generate a tweet from the newly made bot
    print(bot.generate_text(140))
    bots[path[:-4].replace('-',' ')]=bot
print(bots)


As members of Congress to work has the law and don't even know it.
Together we're going to overturn legislation passed by states that calls for massive tax cuts to basic needs.
I have thousands of jobs and wants massive tax hikes.
He may be up at 3 o'clock in the world is watching what we build, but the hospital wouldn't admit her without proof of insurance.
As we look ahead to the @Warriors, a great moral voice of our children.
It's time to take on the debate stage with Hillary Clinton in November #RNCinCLE.
{'Ted Cruz': <markovbot.MarkovBot object at 0x000001F23076F908>, 'Donald Trump': <markovbot.MarkovBot object at 0x000001F22EBA1400>, 'President Obama': <markovbot.MarkovBot object at 0x000001F22F262080>, 'Bernie Sanders': <markovbot.MarkovBot object at 0x000001F22EA9BD30>, 'Barack Obama': <markovbot.MarkovBot object at 0x000001F22CFDDE48>, 'Hillary Clinton': <markovbot.MarkovBot object at 0x000001F22EAA55F8>}

In [33]:
#log into the Donald and Hillary twitter accounts with the api keys
for pres in presidents:
    bots[pres].twitter_login(keys[pres]['cons_key'],keys[pres]['cons_secret'],keys[pres]['access_token'],keys[pres]['access_token_secret'])

Set all three twitter bots to tweet every 10 minutes


In [34]:
for bot in bots:
    bots[bot].twitter_tweeting_start(days=0, hours=0, minutes=10, keywords=None, prefix=None, suffix=None)

In [35]:
for bot in bots:
    bots[bot].twitter_tweeting_stop()

Automatically respond to tweets that contain 'crooked'. Always gets some angry responses.


In [36]:
bots['Hillary Clinton'].twitter_autoreply_start('crooked', mindelay=1.5)

In [37]:
bots['Hillary Clinton'].twitter_autoreply_stop()

Train bots on all the 2016 presidential candidates' campaign speeches.


In [41]:
speech_bots = {}

#make a markov bot for each politician's campaign speeches
speech_paths = [f for f in os.listdir(speech_root) if os.path.isfile(os.path.join(speech_root, f)) and 'Fiorina' not in f]
for path in speech_paths:
    bot = MarkovBot()
    corpus = os.path.join(speech_root, path)
    bot.read(corpus)
    #Generate a tweet from the newly made bot
    print(bot.generate_text(140))
    speech_bots[path[:-4].replace('-',' ')]=bot
print(speech_bots)


We have our chairman, which is the number of people they really all.
Making -- there are 11 million undocumented people cannot continue to fight and keep our pension promise to you.
So we had to make the best states in the world, where you could get ahead if you want somebody else.
You see, the reason that's true is because we have an economy that is bankrupting our country.
So, we are going to have millions and millions of talented, aspiring Americans on the ladder of a dirt road.
Let us move forward so that just as the foundation of that young child growing up in that small town believed in ourselves.
Our democracy is to pay them.
It's everybody's test, and it's wide open exactly as a reliable actor in the defeat of radical Islamic terrorism wherever it appears.
We know that because of the importance of Vietnam when it transitions from an RFD-TV viewer, Senator.
This is exactly what I've done in the Oval Office, I will also provide support and friendship for our values and ideas.
I was at a Republican breakfast with the struggling Americans trying to compete really, really hard to earn.
There is no coherent strategy to defeat ISIL and the example my parents set for me.
I'll be in Nashua, but I have come here tonight to make this announcement at the dawn of the United States.
As many of you gradually stood up in the program this summer.
I've got to have won with the right, we will do whatever it takes to be in a state that believed that a lot of it than he did.
She spent hours with me as together we seek a new government program, or we could be detained without a lawyer?
There are two approaches, and even the nature of the teachers lived on campus.
Bureaucrats in Washington don't care about the other day and draw contrasts.
Today sadly, under the Obama/Clinton doctrine, America is a can-do kind of plan work well under President Ronald Reagan.
And there is a political establishment that cynically breaks its promises, and that the purpose of the Bill of Rights.
{'Lincoln Chafee': <markovbot.MarkovBot object at 0x000001F24A4737F0>, 'Ben Carson': <markovbot.MarkovBot object at 0x000001F24362E470>, 'Lindsey Graham': <markovbot.MarkovBot object at 0x000001F24F7F9C88>, 'Scott Walker': <markovbot.MarkovBot object at 0x000001F254668320>, 'Marco Rubio': <markovbot.MarkovBot object at 0x000001F24F7F9048>, 'Rick Perry': <markovbot.MarkovBot object at 0x000001F25460BDD8>, 'Hillary Clinton ': <markovbot.MarkovBot object at 0x000001F245C4CBE0>, 'Ted Cruz': <markovbot.MarkovBot object at 0x000001F25638A208>, 'John Kasich': <markovbot.MarkovBot object at 0x000001F24A449160>, 'Donald Trump': <markovbot.MarkovBot object at 0x000001F245A52C50>, 'Rand Paul': <markovbot.MarkovBot object at 0x000001F254432D30>, 'Bernie Sanders': <markovbot.MarkovBot object at 0x000001F2438B0518>, 'George Pataki': <markovbot.MarkovBot object at 0x000001F2453E2B70>, 'Mike Huckabee': <markovbot.MarkovBot object at 0x000001F2540C6C50>, 'Bobby Jindal': <markovbot.MarkovBot object at 0x000001F2438B0D68>, 'Jeb Bush': <markovbot.MarkovBot object at 0x000001F247D0C668>, 'Chris Christie': <markovbot.MarkovBot object at 0x000001F2453E2A90>, 'Jim Webb': <markovbot.MarkovBot object at 0x000001F2453E8358>, 'Rick Santorum': <markovbot.MarkovBot object at 0x000001F254933EB8>, "Martin O'Malley": <markovbot.MarkovBot object at 0x000001F24A65E9E8>}

In [39]:
for speech_bot in speech_bots:
    print(speech_bot)
    for i in range(10):
        print(speech_bots[speech_bot].generate_text(140))
    print('\n\n')


Lincoln Chafee
So we've got to surpluses, the last 10, 14 years.
Eighteen of us who originally sponsored it and I just about fell off my chair.
As one who voted against Iraq War and the United Nations is going to pay for it.
In fact, we had a great pleasure to join the choices out there.
If we're smart with our diplomacy, we can come out of these subsidies for agricultural products in particular.
Let's get out of college with while many, many Americans are our professional diplomats stationed all over the world.
[On LGBT issues] Yes, I've had a chance to own their own reasons for voting no.
[On LGBT issues] Yes, I've had a bill to do more for Native Americans.
First, just don't make mistakes, and I was just looking at it the other people in the Pentagon.
Let's join the rest of the Republicans running for president today.



Ben Carson
That is why we are probably at least in her opinion.
[cheers and applause] I am Ben Carson and I am probably never going to do, to try to rule us.
I don't care if you have seen before because it is going to do, to try to maintain her independence.
You guys have an almost sacred position in a place where they're always going to be executed he said that this country was designed.
We have to have a deleterious effect on what happens in your life is dependent upon a well-informed and educated populace.
But, he said my only regret is that people are down on our nation.
The notion that a Hillary Clinton is that people are the rulers of thought in this auditorium, sitting right over there.
And I think the government, as described in our wallet says, "In God We Trust.
But I want to be dependent on the establishment against all odds.
You need to know is that you can gain experience in solving problems.



Lindsey Graham
? And at the battalion level, making them far more likely the people and place I come from.
Today's event comes while the United States invaded Iraq based on conditions on the sidelines.
Their undoing is no coherent strategy to defeat our enemies.
As President, I would also allow us an effective inspections regime.
What's more, the failures of the United States isn't firm in supporting the one and only Jewish state.
If the United States because I am lucky to have Darlene as my aunt and uncle who took care of me.
But first you will not let up until we know they will not be subject to being captured or killed.
As for determined will, President Obama to bring security and our friendship is unbreakable.
As President, I would say to the remainder of his presidency.
The upcoming presidential election and the overwhelming majority of ISIL and wreaking havoc on African soil.



Scott Walker
I will push to take the power from the hands of the United States of America.
In the end, I believe that the shirt was $29.
Most of all I want to be leaders in unusual ways.
Today I believe that you can spend your own business, live your own money far better than the minimum wage.
I believe that the Bible is full of stories about people who came here from other places around the world.
To help live that dream, we have a President who will stand up for college.
I'm for transferring power from the clumsy hands of the few places left in the State of Wisconsin.
Then, like so many wonderful people stepped up to the people that put their lives on the government.
My fellow Americans, you have a President who will stand up for college.
We know that Tonette and I enjoyed going over to the levels recommended by Secretary Gates.



Marco Rubio
And as a nation and they will ultimately bankrupt our country.
There are young people in America borrowing thousands of people like them could have a place where you come from power and privilege.
While it's not legally the I mean, they use terrorism the way we enforce immigration laws.
And even under the control of a radical left-wing view that America doesn't owe me anything; but I guess the spell check changed it to be.
I'll be in Nashua, but I have full confidence that in our country.
I look at these things are important it will be the first step with me, by joining us at marcorubio. com.
What if that generation of Americans harnessed the power of the vast growth of regulations.
And then 90 days later, he'd do the same future as those who come from power and wealth belonged only to a vacuum which leads to chaos.
What that means in other parts of the chief executive and the purpose of my life.
I will be prepared to seize it, to be president.



Rick Perry
And before I leave, I will authorize the I will continue to fight for the reality television star is a lack of jobs.
Resentment is the first states to be able to replicate their astounding success all over the objections of the regulatory state.
We shouldn't be forced to join one to the nation they would never end.
Under my plan, you will no longer politicize them, and taxpayers will be too.
"Because of the solution is under a crushing burden of Chris' legacy, but the evidence of its doldrums, and renew American prosperity.
My plan does not bow down to the crisis at the end of an era of fiscal austerity.
We will work with Congress to determine the right nominee, we can love all who live here and those who lived by the excess litigation.
Thanks to President Obama, but to God.
I believe in the potential of private enterprise, set free from the hearts of every candidate will be attacked.
The reason I am running to be called a town, but it was a man offered the chance to go to a flat, fair 20 percent.



Hillary Clinton 
We're going to give both LaKeisha and the Soviet Union while thousands of Americans basically stall.
The Administration was taking our troops home as soon as you may know, think about what I've been as First Lady.
They are compounding the tragedy of AIDS and was signed into law, helping to develop clean energy future.
When people lose coverage or change our trade deficit comes from faith.
I'm here as Maggie and Elizabeth and I think the American people have lost confidence that they don't begin to explore it.
Earlier you heard from Senator Sanders and I want to talk to anybody, you gotta well root them on.
Or you can work together with respect to the economy.
She had not led, it would give you one, which is a very competitive global economy.
Countries across the Country face when it comes time to restore America's leadership in the first time in our country.
Hear her express the outrage and just feeling such despair.



Ted Cruz
. . . that might actually get the House of Representatives, then things will be a champion for Israel.
But today, I give you a very personal level, for me, much of human life.
I appreciate the enthusiasm of the foundational principles they sought to proclaim and the people of faith all across this country.
They are the words that led two men in their garage to come back too.
That is the power of the next few months, we will destroy them.
I'll tell you, I'm proud to stand up and lead, or when the forces of good are divided, evil can prevail.
God bless each and every Democrat on the power of serious, conservative thought leaders.
Not a single mom without my father in the next few months, we will destroy them.
I want to ask of every American.
Now, Hillary Clinton and Donald Trump have said that standing with hardworking men and women in this nation.



John Kasich
Folks, let me stress, I will support Congress's efforts to do nothing more than 35 years of my career in public service.
The Administration's desire for an Iran nuclear deal in reaction to Iran's attempts to develop nuclear weapons.
We need to balance our budget, and we need and part company with consistent under-performers.
Yet it is fair to say what we believe, how do we have in place high threshold criteria for design changes.
The challenge posed by ISIS, I believe America is not our battle alone.
But at each moment we came out stronger because of our great friend.
Israel is the only democracy in the Oval Office, I will provide the growth we need to recommit ourselves to those values.
And I will provide the Afghan national security interests of America and so much love our great friend.
Because leadership has not been the federal government's strength, and we can sit together and be realistic about what we can see today.
Relationships with our allies to significantly increase our military dollars, especially on weapons systems.



Donald Trump
"Nothing is more poverty, more crime, and more fulfilled than to be able to attend the school choice programs.
It is going to fight for the Latino community than Donald Trump, nobody, nobody.
And also if the ordinary decent people are provided the information they need to show the whole world that America is deep.
I am going to win back the White House, and it's a total disaster, by the time -- actually, it never worked out.
Hillary Clinton is an attack on the right of all Americans women and children living in poverty.
it has been a disaster for job in her book, or the private doctor or their rent which, by the United States Supreme Court.
We need a national goal of 350 surface ships and submarines, as recommended by the way, our policeman are great, great people.
I'm not making things in America that is trying to infiltrate refugee flows coming into our country, we don't need Orlando and problems.
And, I mean that that the country lost badly under Hillary Clinton from outside government were with foundation donors.
While my opponent slanders you as no one from our politicians.



Rand Paul
If you want to see millions of records is not in session.
When we were the party that defends the entire Bill of Rights nobody on the enemy.
The short answer is the same time.
Everything goes well for the high school quarterback's always going to come home.
And people say all the votes of people who have enjoyed the American Dream.
Our founding fathers were so prescient in the middle of a sudden, if we defend against enemies who are here today.
We've brought Iran to the ophthalmologist as she had begged him to get poorer and the Iraqis are sort of our abundance of resources.
And then the courts get involved, and the parents disagree, and the pursuit of happiness.
An electrical charging station for the high school quarterback's always going to do at the White House and said those same words.
With my parents' help, I was disappointed the Republicans were voting for bank bailouts.



Bernie Sanders
And that's the situation is worse now.
You want to share his personal story of America, our great campaign staff.
Preventing Iran from getting into the debate.
That would simply prolong the war in Iraq, and that has everybody's support.
Further, it makes a lot of effort to end segregation in America.
But the world which invests in jobs and how difficult, how difficult this family has faced because what hard work with economic mobility.
Republicans win when people are saying and I hope very much for -- afford to feed their kids, to pay their fair share of taxes.
And if we do not matter, that their children or for not for breast cancer because it is totally, totally insane.
Take a look where you had what had been a choice, austerity in Greece and I know that it is not a privilege.
And I think it was supposed to be quite widespread.



George Pataki
And, in the evening and weekends, we'd work on the farm in a small town in the American way.
And yes, if necessary American force will be above the law, not even if you are banned, go home.
We will defend our freedom, but we will once again astonish the world has ever known; the freedom of working Americans.
While I saw up close the horrible consequences of too many in Washington is not the time to strengthen our military.
And compared to those already fighting ISIS on the basis of politics or religion.
Stand with us, let's go forward together and I am announcing I am the proud product of immigrants.
Yes, the challenge of a better place when America is a policy that works.
We weren't wealthy, we weren't well-connected, we weren't well-connected, we weren't well-connected, we weren't well-known.
Sadly, Washington is not the time to strengthen our military.
Sadly, Washington is not the time to strengthen our military.



Mike Huckabee
Deb Vanderbeek has been willing to compliment him.
And I just want to know that that small business owners.
Well, George Brett that, no matter where you had to stop.
I want you to go to the beginning of this country are saying the conservatives do have a great patriot.
America's leadership in the discussion, but let me say there are some, even in that higher tax break, there's other issues as well.
Neither Janet nor I have so many people in America.
And when we saw that there are these calls to say, "Thanks.
But let me tell you that we helped clear the way I grew up in her yard.
And I'm pretty sure that happens in this nation, this is our presidency, not theirs.
And government ought to live by the name of Haskell Jones.



Bobby Jindal
Instead of their dream is for the folks in Washington, they may call that the legend was true.
They say that we need to hide who we are naive to believe in Louisiana again.
We did what they said could not be silenced in order to win all the time.
Every Republican will say they are trying to reclaim the past.
And when they got here they found that America is indeed the land of the countries they have forgotten their history.
But you and I can, and we will rock the boat, and we will lose again.
I believed him then, and I can, and we will repeal Obamacare.
. It's time to level with the highest incomes in our state's history, with the American Dream.
We did what they said could not be intimidated from talking about the mess that Obama has made of our people.
I will say the things you cannot reduce the size of government bureaucrats by more than 30,000.



Jeb Bush
And whatever China's designs are in the end of the country.
. . . reform that can be sure of If I am certain that we have seen cuts in defense that are lost forever.
They have my word I will win with a quality education and workforce training.
Giving bureaucrats more power over the economy is barely moving forward and American companies, are under cyber-attack every day.
It's easy for politicians and academics to go to the way through not just the rhetoric.
In any language, my message will be like the last thing they want is a regime that is the direction we should share.
With firmness in the air and naval forces.
Meanwhile, here's the impact on working families and the gratitude, respect, and support they deserve.
. . more than could ever be asked, gave more than $2 billion dollars for Iran's security services to use force.
As technology advances, the first rung of the greatest risk of military power to what the Army National Guard.



Chris Christie
That we can make a difference in this hall tonight and those failures are not the end, everybody, leadership matters.
She was the first person in either one of children believes that their president who not only think about my two grandmothers.
She said, all work-related e-mails were sent back to the rest of America today, what do we have to confront?
Now, time, time after time, the truth as I see it and then turning around and doing something else.
We did a coin flip when we were going to give their children and say that our country and it's leadership owes the same verdict.
We made the hard decisions today will lead to growth and opportunity for the cash to finance Barack Obama's bloated stimulus plan.
My wife has been infected by her high school classmates.
And I'm thinking about both of those strong women under really difficult circumstances.
You know, it may be that you know that this is where my family raised me.
But everybody, this election and I met all those years ago, my mother and father became the biggest cheerleader for this moment.



Jim Webb
Well, first of all, there's an $11,000,000 exemption for uh tightening loopholes and uh you say this is a good start, don't go anywhere.
Uh the last statistic I saw it so much and.
. . so the next President of the first is that with.
. . my belief is that when I was in the Senate, I spent a lot of medications right now that we're seeing.
First of all, I voted against that, but I did was uh there were to be resolved.
Since we've had this trade embargo gone, we need to respect their traditions.
. . in East Arkansas at a very long time.
. . the only way that they are uh addressing.
. . when it comes to our country over the past uh couple of years ago that.
. . and my wife and I told him how much it costs just to say, put it for.



Rick Santorum
Folks, we as conservatives, we can't take that right away.
Thanks to the American dream was slipping away.
Because they know that manufacturing, making things, is the government can take that out of poverty.
Who would have a nominee that can deliver what we wanted to get the courts to say, I always have to take power away from you and God bless.
And later on, they were willing to give them back to its constitutional framework, to stand behind us and it's a tough decision.
I just have to create opportunity and hard work, and we'll see how well my daughter did.
That's that's just -- that's not all of them went to Washington and said "game on.
And I'm not going to fight for freedom, with the values that we have to thank my kids, the two thousand years previous it did nothing.
We've were able to accomplish what Reagan accomplished in America, but we were founded different.
Ladies and gentlemen, we've made a great country because, from the bottom up.



Martin O'Malley
The problem of a single Wall Street executive was convicted of a new way of leadership that's emerging throughout our state.
We need to reinstate the full economic participation of our neighbors out of Kuwait.
That is why I say to you and me.
And our parents and grandparents practiced we have reached, of such a pleasure to be this way.
What have we come to now that we share as a nation of fear and anger never built a great people.
The symbol of our own country's potential.
During the debate they were talking with you about the American Dream is on the rise?
And you and I know that some in our neighborhoods and we all agree that every generation to include more and more of our country.
How far we have made our country forward.
We brought forward a new renewable energy solutions and green design.




In [ ]:


In [ ]: